package cc.openhome;

import cc.openhome.Client;
import cc.openhome.ClientEvent;
import cc.openhome.ClientListener;
import cc.openhome.ClientQueue;

/**
 * Created by xuzhihan on 17/3/19.
 */
public class MultiChat {
    public static void main(String[] args) {
        Client c1 = new Client("127.0.0.1","cat");
        Client c2 = new Client("192.168.0.2","dog");
        ClientQueue queue = new ClientQueue();
        queue.addClientlistener(new ClientListener() {
            @Override
            public void clientadd(ClientEvent event) {
                System.out.printf("%s 从 %s 联机%n",event.getName(),event.getip());
            }

            @Override
            public void clientRemoved(ClientEvent event) {
                System.out.printf("%s 从 %s 联机 %n",event.getName(),event.getip());

            }
        });
        queue.add(c1);
        queue.add(c2);
        queue.remove(c1);
        queue.remove(c2);
    }
}
